import request from '@/utils/request';
import { TableListParams } from './data';
import * as RequestHelper from '@/helpers/RequestHelper';

export async function queryRule(params?: any) {
  // @ts-ignore
  return request('/api/admin/tweetconfigs/index', { params }).then(response => {
    return response
  });
}

export async function removeRule(params: any) {
  return request('/api/admin/tweetconfigs/destroyLang', {
    method: 'POST',
    data: {
      ...params,
      method: 'delete',
    },
  });
}

export async function addRule(params: TableListParams) {
  return request('/api/admin/tweetconfigs/storeLang', {
    method: 'POST',
    data: {
      ...params,
      method: 'store',
    },
  });
}

// 
export async function updateItemRule(params:any) {
  return request('/api/admin/tweetconfigs/updateLang', {
    method: 'POST',
    data: {
      ...params,
      method: 'update',
    },
  });
}

export async function updateRule(params:any) {
  return request('/api/admin/tweetconfigs/update', {
    method: 'POST',
    data: {
      ...params,
      method: 'update',
    },
  });
}

//设置默认
export async function setDefaultRule(params:any) {
  return request('/api/admin/tweetconfigs/updateDefaultLanguage', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

//是否开启多语言 
export async function setMulLangRule(params:any) {
  return request('/api/admin/tweetconfigs/updateLanguageStatus', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

//更新排序  /api/admin/tweetconfigs/updateRankNum
export async function updateRankRule(params:any) {
  return request('/api/admin/tweetconfigs/updateRankNum', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

//语言包列表  
export async function queryPackgeList(params: any) {
  return request('/api/admin/tweetconfigs/pack/index', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

//语言包配置项新增
export async function addLangPackage(params: any) {
  return request('/api/admin/tweetconfigs/pack/store', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

//语言包配置项删除
export async function removeLangPackage(params: any) {
  return request('/api/admin/tweetconfigs/pack/destroy', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

//语言包配置项编辑
export async function updateLangPackage(params: any) {
  return request('/api/admin/tweetconfigs/pack/update', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

//根据洲查地区 
export async function getAreaByContinent(id: any) {
  return request('/api/admin/tweetconfigs/getAreaCode', {
    method: 'GET',
    params: {
      id,
    },
  });
}